package org.microsites.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.microsites.domain.dao.ShareDAO;
import org.microsites.domain.model.Entity;
import org.microsites.domain.model.Share;
import org.microsites.service.ServerService;
import org.microsites.service.ShareService;

public class ShareServiceImpl extends GenericServiceImpl<Share> implements ShareService {

	private ShareDAO shareDAO;
	private ServerService serverService;
	
	@Override
	public ShareDAO getDAO() {
		return shareDAO;
	}

	public void setShareDAO(ShareDAO shareDAO) {
		this.shareDAO = shareDAO;
	}

    @Override
    public List<Entity> loadPath(Long id) {
        if (id == null) return new ArrayList<Entity>();

        Share d = this.load(id);
        if (d == null) return new ArrayList<Entity>();
        
        List<Entity> list = serverService.loadPath(d.getServer());
        list.add(d);

        return list;
    }

    public ServerService getServerService() {
        return serverService;
    }

    public void setServerService(ServerService serverService) {
        this.serverService = serverService;
    }
}
